//
//  UIButton+Beautiful.m
//  mmbang
//
//  Created by 肖信波 on 13-8-28.
//  Copyright (c) 2013年 iyaya. All rights reserved.
//

#import "UIButton+Beautiful.h"


@implementation UIButton (Beautiful)

+ (id)buttonWithBeautifulType:(UIButtonBeautifulType)type
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    switch (type) {
        case UIButtonBeautifulTypeNormal:
            // TODO 4.0版本 暂时没有这样的按钮
            [button setBackgroundImage:[[UIImage imageNamed:@"button_normal"] stretchableImageWithLeftCapWidth:5 topCapHeight:5] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeGreen:
            [button setBackgroundImage:[TKUtil createImageFromColor:RGBA_COLOR(56, 159, 73, 1.0f)] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeBlue:
            [button setBackgroundImage:[TKUtil createImageFromColor:RGBA_COLOR(51, 152, 206, 1.0f)] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypePink:
            [button setBackgroundImage:[TKUtil createImageFromColor:RGBA_COLOR(255.0f, 62, 137, 1.0f)] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeMain:
            [button setBackgroundImage:[TKUtil createImageFromColor:[UIColor colorWithHex:kMainColor alpha:1]] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeYellow:
            [button setBackgroundImage:[TKUtil createImageFromColor:RGBA_COLOR(255.0f, 207, 0, 1.0f)] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeOrange:
            [button setBackgroundImage:[TKUtil createImageFromColor:RGBA_COLOR(255.0f, 105, 0, 1.0f)] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeLightOrange:
            [button setBackgroundImage:[TKUtil createImageFromColor:RGBA_COLOR(251, 185, 98, 1.0f)] forState:UIControlStateNormal];
            break;
        case UIButtonBeautifulTypeRedBorder:
            button.backgroundColor = [UIColor whiteColor];
            button.layer.borderColor = [[UIColor colorWithHex:0xf47b56 alpha:1] CGColor];
            button.layer.borderWidth = 1;
            button.layer.cornerRadius = 3.0;
            [button setTitleColor:[UIColor colorWithHex:0xe25b4a alpha:1] forState:UIControlStateNormal];
            break;
        default:
            break;
    }
    
    [button.layer setCornerRadius:3];
    [button.layer setMasksToBounds:YES];
    return button;
}

@end
